package cn.seocoo.platform.common.config.pay;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author WuJian
 * @Description 支付宝
 * @Date 11:31 2019/11/25
 * @Param
 * @return
 **/
@Component
public class AlipayConfig {

    /**
     * 支付来源 APP
     */
    public static final String PAY_SOURCE_APP = "1";

    /**
     * 支付来源 PC
     */
    public static final String PAY_SOURCE_PC = "2";


    //<--------------------------------配置文件配置的参数->开始:------------------------------->


    public static String payUrl;


    public static String notifyUrl;


    public static String appId;

    public static String returnUrl;

    public static String getPayUrl() {
        return payUrl;
    }

    @Value("${aliPayPara.payUrl}")
    public  void setPayUrl(String payUrl) {
        AlipayConfig.payUrl = payUrl;
    }

    public static String getNotifyUrl() {
        return notifyUrl;
    }

    @Value("${aliPayPara.notifyUrl}")
    public  void setNotifyUrl(String notifyUrl) {
        AlipayConfig.notifyUrl = notifyUrl;
    }

    public static String getAppId() {
        return appId;
    }

    @Value("${aliPayPara.appId}")
    public  void setAppId(String appId) {
        AlipayConfig.appId = appId;
    }

    @Value("${aliPayPara.returnUrl}")
    public  void setReturnUrl(String returnUrl) {
        AlipayConfig.returnUrl = returnUrl;
    }

    //<--------------------------------配置文件配置的参数->结束------------------------------->

    //<--------------------------------商户申请支付宝账户生成的秘钥和私钥->开始------------------------------->
    /**
     * 商户的私钥(应用私钥),需要PKCS8格式，RSA公私钥生成：https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.nBDxfy&treeId=58&articleId=103242&docType=1
     **/
    public static String sign = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC7nWUTkFbNnD2m85pCb9ycC7P9x4vabMQ/6kvo63uGarYT4sWy5Csa7qt16sfB8tezwrKGQvduwJBZqG55DnrbhhZsPfRcp7w9P5B6ozlvKPyTz0L/oDaf8cEmucYt8iLMFf5chTgDo8ftVhw/rlzqnErmHNOJlp8UboG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O2nlRFCuRJgibBkYrvhxHQKbMPGDlg6sgxmVYD3lynZIkevZLTGFuoVD4VaV8Ra8F7ykELIaldO8qh7434gJW3zyStgyDOlvZTXLx87EAoW6PHk8f8iQfNx4uB8J7KdjPQ5bhBW2SDkCgYBXhqLzvYtj+4rOGVGs0Wh/RJzuSzlUNo6RGJVJuWVhwB6CJ2WnM46sTK0h6ZUmupMnV0b73h+gbOoyq64cQSKi/uTbC08U0tAhi+mOx9zB/uoNntR3R2hxoQifZwZ1zD18zKdP8VzMyh8Nbmkt2MgnzleQ/63j2iKkqKJx+XMJNA==";


    /**
     * 支付宝的公钥,查看地址：https://b.alipay.com/order/pidAndKey.htm
     **/
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgcw7SZlszOTnRqNDSvoFqYHVQvIBvmbTlJrzCWtV2+iz0gC0NpMkWHAXe9CieXkoRXY7k7nQoUOB+07if47JdjvZ6ZumQ7VtWsF2v7ABEFy+ElDkm0XGHYBvHiF7hAatvot9aONf535r0gNH0bGGxhYmQz4hN4oUPxwpKdHxBL40ryZPqRInarvK6hDxHkBUWY6PCppQ2yPtL003wCOP0Ix+H3aDZO4cSw0pIEvcXpXxprvyWqc78k++eDGy9tEmiNxMu3fYjT+SneaKTIRN8vRSmVngxXyIRVP2s8PiTsv0qHapV4xJ8VnCYpka1jf3WqNdYqnkp5Rsl6TuBwDwhQIDAQAB";
    //<--------------------------------商户申请支付宝账户生成的秘钥和私钥->结束------------------------------->


    //<--------------------------------固定参数不变->开始------------------------------->


    public static String charset = "UTF-8";
    /**
     * 签名方式
     **/
    public static String sign_type = "RSA2";


    /**
     * 调用的接口版本，固定为：1.0
     **/
    public static String version = "1.0";

    /**
     * 支付类型 ，无需修改
     **/
    public static String payment_type = "1";


    public static String format = "json";


    /**
     * 对一笔交易的具体描述信息。如果是多种商品，请将商品描述字符串累加传给body
     **/
    public static String body = "二手车交易平台";

    /**
     * 商品的标题/交易标题/订单标题/订单关键字等
     **/
    public static String subject = "二手车交易平台";

    //<--------------------------------固定参数不变->结束------------------------------->

    /**
     * @return com.alipay.api.AlipayClient
     * @Author WuJian
     * @Description //实例化客户端
     * @Date 10:05 2019/11/25
     * @Param 参数：网关地址、商户appid、商户私钥、格式、编码、支付宝公钥、加密类型），为了取得预付订单信息
     **/
    public static AlipayClient initClient() {

        AlipayClient alipayClient = new DefaultAlipayClient(payUrl, appId, sign, format, charset, alipay_public_key, sign_type);
        return alipayClient;
    }






}

